﻿using System;
using System.Collections.Generic;
using System.Text;
using HostTool.Util;

namespace HostTool.Core
{
    /// <summary>
    /// 记录板
    /// </summary>
    class BoardRecord :Board
    {
    
        public BoardRecord(HostMachine machine)
            : base(machine)
        {


            AddCPU(new CPURecord(this));
            AddCPU(new CPUSample(this));


        }

        public override string Name
        {
            get { return "记录板"; }
        }
        

    }

    /// <summary>
    /// 记录CPU
    /// </summary>
    class CPURecord :CPU
    {

        public CPURecord(IBoard board)
            : base(board,0x0ab4,0x0ab6)
        {
            IniDocument config = this.Board.Machine.ConfigDoc;
            //包含2个电压通道
            for (int i = 0; i < 2; i++)
            {
                string channelName = "电压通道"+i;
                if (config != null)
                {
                  string name=  config.GetString("记录板记录CPU通道", "通道"+i);
                  if (!string.IsNullOrEmpty(name))
                  {
                      channelName = name;
                  }

                }
                listChannel.Add(new CPUChannel(channelName, i));
            }
            AddFirmware(new FirmwareType("主APP(Main)", 0x13));
            AddFirmware(new FirmwareType("USB程序", 0x73));
        }

        public override string Name
        {
            get
            {
                return "记录CPU";
            }
        }
        public override byte DstPort
        {
            get
            {
                return 0x20;
            }
        }
        public override int MTU
        {
            get
            {
                return 1 * 1024;
            }
        }

    }

    /// <summary>
    /// 采样CPU
    /// </summary>
  public  class CPUSample:CPU
    {
        public CPUSample(IBoard board)
            : base(board,0x0ab0,0x0ab2)
        {
            IniDocument config = this.Board.Machine.ConfigDoc;
            //包含26个电压通道+温度通道
            for (int i = 0; i <= 26; i++)
            {
                string channelName = "电压通道" + i;
                if (config != null)
                {
                    string name = config.GetString("记录板采样CPU通道", "通道" + i);
                    if (!string.IsNullOrEmpty(name))
                    {
                        channelName = name;
                    }

                }
                listChannel.Add(new CPUChannel(channelName, i));
            }
            AddFirmware(new FirmwareType("采集APP",0x12));
        }

        public override string Name
        {
            get
            {
                return "采样CPU";
            }
        }
        public override byte DstPort
        {
            get
            {
                return 0x21;
            }
        }
        public override int MTU
        {
            get
            {
                return 16 * 1024;
            }
        }
    }
}
